package com.aeye.mbr.common.base.constants;
/**
 * socket错误码枚举
 */
public enum SocketErrorCodeConstants{
	COMMUNICATION_SUCCESS(0,"成功"),
	TYPE_PARAMETER_NOT_VALID(1,"算法类型参数不合法"),
	FUNCTION_PARAMETER_NOT_VALID(2,"功能号参数不合法"),
	CHARACTERISTIC_NUM_NOT_VALID(3,"特征组数量不合法"),
	CHARACTERISTIC_DATA_NOT_VALID(4,"特征组数据不合法"),
	CHARACTERISTIC_TWO_NUM_NOT_VALID(5,"特征组2数量不合法"),
	CHARACTERISTIC_TWO_DATA_NOT_VALID(6,"特征组2数据不合法"),
	IMAGE_NUM_NOT_VALID(7,"图像组数量不合法"),
	IMAGE_DATA_NOT_VALID(8,"图像组数据不合法"),
	IMAGE_TWO_NUM_NOT_VALID(9,"图像组2数量不合法"),
	IMAGE_TWO_DATA_NOT_VALID(10,"图像组2数据不合法"),
	OTHER_ELEVEN(11,"其他"),
	FACE_DETECTION_FAIL(-1,"人脸检测失败"),
	EYE_DETECTION_FAIL(-2,"人眼检测失败"),
	CHARACTERISTIC_EXTRACT_FAIL(-3,"特征抽取失败"),
	COMPARISON_FAIL(-4,"比对失败"),
	OTHER_MINUS_FIVE(-5,"其他"),
	
	UNKNOWN_ERROR(-2333,"未知异常");
	
	private SocketErrorCodeConstants(int code,String msg){
		this.code = code;
		this.msg = msg;
	}
	int code; 
	String msg;
	public int getCode() {
		return code;
	}
	public String getMsg() {
		return msg;
	}
	
	public static SocketErrorCodeConstants init(int code){
		for(SocketErrorCodeConstants sec : values()){
			if(sec.getCode() == code){
				return sec;
			}
		}
		return UNKNOWN_ERROR;
	}
	
	public ErrorCodeConstants toErrorCodeConstants()
	{
		ErrorCodeConstants ret = null;
		switch (this) {
		case TYPE_PARAMETER_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_TYPE_PARAMETER_NOT_VALID;
			break;
		case FUNCTION_PARAMETER_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_FUNCTION_PARAMETER_NOT_VALID;
			break;
		case CHARACTERISTIC_NUM_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_CHARACTERISTIC_NUM_NOT_VALID;
			break;
		case CHARACTERISTIC_DATA_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_CHARACTERISTIC_DATA_NOT_VALID;
			break;
		case CHARACTERISTIC_TWO_NUM_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_CHARACTERISTIC_TWO_NUM_NOT_VALID;
			break;
		case CHARACTERISTIC_TWO_DATA_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_CHARACTERISTIC_TWO_DATA_NOT_VALID;
			break;
		case IMAGE_NUM_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_IMAGE_NUM_NOT_VALID;
			break;
		case IMAGE_DATA_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_IMAGE_DATA_NOT_VALID;
			break;
		case IMAGE_TWO_NUM_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_IMAGE_TWO_NUM_NOT_VALID;
			break;
		case IMAGE_TWO_DATA_NOT_VALID:
			ret = ErrorCodeConstants.ALGORITHM_IMAGE_TWO_DATA_NOT_VALID;
			break;
		case CHARACTERISTIC_EXTRACT_FAIL:
			ret = ErrorCodeConstants.FEATURE_EXTRACT_FAIL;
			break;
		case OTHER_ELEVEN:
			ret = ErrorCodeConstants.ALGORITHM_OTHER_ELEVEN;
			break;
		default:
			ret = ErrorCodeConstants.ALGORITHM_OTHER_ELEVEN;
			break;
		}
		return ret;
	}
}
